import { EntitySchema } from '@mikro-orm/core';

export class TypechoFields {
  cid!: number;
  name!: string;
  type?: string;
  strValue?: string;
  intValue?: number = 0;
  floatValue?: number = 0;
}

export const TypechoFieldsSchema = new EntitySchema({
  class: TypechoFields,
  properties: {
    cid: { primary: true, type: 'number' },
    name: { primary: true, type: 'string', length: 150 },
    type: { type: 'string', length: 8, nullable: true, default: 'str' },
    strValue: { type: 'string', columnType: 'text', nullable: true },
    intValue: { type: 'number', nullable: true, default: 0, index: 'int_value' },
    floatValue: {
      type: 'number',
      columnType: 'float',
      nullable: true,
      default: 0,
      index: 'float_value',
    },
  },
});
